package com.company.class4;

/**
 * @Classname Dog
 * @Description 类型说明
 * @Date 2022/4/16 17:40
 * @Created by zbw
 */

public class Dog{

    public String name;//狗狗名字
    public String cry;//狗狗叫声
    int age = 0;//狗狗年龄

    //构造方法
    public Dog(String name){
        this.name = name;
    }

    //狗叫的方法，通过判断狗叫确定狗状态
    public void dog_Cry(){

        if(this.cry.equals("呜呜叫")){
            System.out.println(this.name+"现阶段是小狗");
        }else if(this.cry.equals("汪汪叫")){
            System.out.println(this.name+"现阶段是大狗");
        }else if(this.cry.equals("嗷嗷叫")){
            System.out.println(this.name+"现阶段是老狗");
        }
    }

    //通过线程等待实现成长
    public void grow_Up() throws InterruptedException {
        try {
            System.out.println(this.name+"------------在成长中");
            //加入等待
            Thread.sleep(5000);
            this.age += 5;
        }catch (Exception e){
            System.out.println(e);
        }finally {
            System.out.println(this.name+this.age+"岁了");
        }

    }

    //狗狗的状态
    public void dog_State(){
        if(this.age < 5){
            System.out.println(this.name+"现阶段是小狗");
            System.out.println("呜呜叫");
        }else if(this.age >= 5 && this.age <= 10){
            System.out.println(this.name+"现阶段是大狗");
            System.out.println("汪汪叫");
        }else{
            System.out.println(this.name+"现阶段是老狗");
            System.out.println("嗷嗷叫");
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCry() {
        return cry;
    }

    public void setCry(String cry) {
        this.cry = cry;
    }
}
